//
//  BRHomeBottomView.m
//  BrezzeSaaS
//
//  Created by IOS on 2021/9/22.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import "BRHomeBottomView.h"

@interface BRHomeBottomView ()
{
    UIImageView *_headImg;
    QMUILabel *_nameLabel;
}
@end

@implementation BRHomeBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUI];
    }
    return self;
}



- (void)iconTouch:(QMUIButton *)btn {
    if (self.delegate && [self.delegate respondsToSelector:@selector(bottomViewClickBtns:)]) {
        NSInteger index = btn.tag - 100;
        [self.delegate bottomViewClickBtns:index];
    }
}

- (void)scanTouch:(QMUIButton *)btn {
    if (self.delegate && [self.delegate respondsToSelector:@selector(bottomViewClickScan:)]) {
        [self.delegate bottomViewClickScan:btn];
    }
}

- (void)headTouch{
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(bottomViewClickHeadIcon)]) {
        [self.delegate bottomViewClickHeadIcon];
    }
}

#pragma mark - setUI --
- (void)setUI {
    
    self.backgroundColor = UIColor.clearColor;
    
    UIView *shadowV = [[UIView alloc] init];
    shadowV.backgroundColor = UIColorClear;

    QMUIButton *scanBtn = [[QMUIButton alloc] qmui_initWithImage:UIImageMake(@"home_ic_scan") title:Localized(@"home_scan2rent")];
    [scanBtn setTitleColor:UIColorWhite forState:UIControlStateNormal];
    scanBtn.titleLabel.font = [UIFont fontB:17];
    scanBtn.layer.cornerRadius = 26;
    scanBtn.layer.masksToBounds = YES;
    [scanBtn jk_setBackgroundColor:kColorMain forState:UIControlStateNormal];
    scanBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
    scanBtn.imagePosition = QMUIButtonImagePositionLeft;
    scanBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 12, 0, 16);
    scanBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 8);
    [shadowV addSubview:scanBtn];
    [scanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(30);
        make.left.offset(14);
        make.right.offset(-14);
        make.height.mas_equalTo(52);
    }];
    [scanBtn addTarget:self action:@selector(scanTouch:) forControlEvents:UIControlEventTouchUpInside];
    
    // 136
//    UIImage *bubble = UIImageMake(@"home_btnBorder");
//    UIImageView *bgV = [[UIImageView alloc] init];
//    bgV.image = [bubble resizableImageWithCapInsets:UIEdgeInsetsMake(0, 100, 0, 140) resizingMode:UIImageResizingModeStretch];
//    bgV.contentMode = UIViewContentModeScaleToFill;
//    
//    [shadowV addSubview:bgV];
//    [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.offset(16);
//        make.right.offset(-16);
//        make.top.offset(16);
//        make.height.mas_equalTo(84);
//    }];
    
    [self addSubview:shadowV];
   
    [shadowV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(0);
        make.right.offset(0);
        make.top.offset(0);
        make.bottom.offset(0);//添加阴影到底部
    }];
    
    
//    QMUIButton *listBtn = [[QMUIButton alloc] init];
//    [listBtn setBackgroundColor:UIColor.qd_tintColor6];
//    [listBtn setImage:UIImageMake(@"home_ic_node") forState:UIControlStateNormal];
//    listBtn.layer.cornerRadius = 26;
//    [shadowV addSubview:listBtn];
//    [listBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.height.mas_equalTo(52);
//        make.centerY.equalTo(bgV.mas_centerY).offset(0);
//        make.right.equalTo(bgV.mas_right).offset(-16);
//    }];
//    listBtn.tag = 102;
//    [listBtn addTarget:self action:@selector(iconTouch:) forControlEvents:UIControlEventTouchUpInside];
    
//    UIView *btnShadow = [[UIView alloc] init];
//    btnShadow.backgroundColor = UIColor.clearColor;
//    [self addSubview:btnShadow];
//    [btnShadow mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.height.mas_equalTo(52);
//        make.top.offset(0);
//        make.right.offset(-33);
//    }];
    
//    QMUIButton *locaBtn = [[QMUIButton alloc] init];
//    [locaBtn setBackgroundColor:UIColor.qd_tintColor5];
//    [locaBtn setImage:UIImage.qd_homeLocationImg forState:UIControlStateNormal];
//    locaBtn.imageView.contentMode = UIViewContentModeCenter;
//    locaBtn.layer.cornerRadius = 25;
//    locaBtn.layer.masksToBounds = YES;
//    [btnShadow addSubview:locaBtn];
//    [locaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.offset(0);
//    }];
//    locaBtn.tag = 101;
//    [locaBtn addTarget:self action:@selector(iconTouch:) forControlEvents:UIControlEventTouchUpInside];
    
//    [self createShadow:btnShadow];
    
    [self createShadow:shadowV];
}

- (void)createShadow:(UIView *)view {
    view.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.12].CGColor;
    view.layer.shadowOffset = CGSizeMake(0,6);
    view.layer.shadowOpacity = 1;
    view.layer.shadowRadius = 16;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
